package com.oa.controller;


import com.oa.oaspccommon.dto.ActionResult;
import com.oa.oaspccommon.po.Salary;
import com.oa.oaspcpersonalcenterapi.api.SalaryServiceApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author AkazaAkari
 * @version 1.0
 * @className MailApiController
 * @description TODO
 * @date 2021/4/13 16:32
 */
@RestController
public class SalaryApiController {
    @Autowired(required = false)
    private SalaryServiceApi salaryServiceApi;
    @GetMapping("/salarys")
    public ActionResult findSalarys(){
        List<Salary> all=salaryServiceApi.findSalarys();
        return new ActionResult(200,"",all);

    }
    @GetMapping("/salary/{uid}&{sid}")
    public  Salary findSalaryByUidAndSid(@PathVariable("uid") int uid, @PathVariable("sid") double sid) {
        Salary salary = salaryServiceApi.findSalaryByUidAndSid(uid,sid);
        return salary;
    }

    @PostMapping("/salary")
    public boolean addSalary(@RequestBody Salary salary) {
        boolean b = salaryServiceApi.addSalary(salary);
        return b;
    }

    @DeleteMapping("/salary")
    public boolean deleteSalaryByUidAndSid(@RequestParam(value = "uid") int uid, @RequestParam(value = "sid") double sid) {
        boolean b = salaryServiceApi.deleteSalaryByUidAndSid(uid,sid);
        return b;
    }

    @PutMapping("/salary")
    public boolean updateSalary(@RequestBody Salary salary) {
        boolean b = salaryServiceApi.updateSalary(salary);
        return b;
    }
}
